<?php
include(dirname(__FILE__).'/inc/config.model.class.php');
include(dirname(__FILE__).'/inc/config.php');
include(dirname(__FILE__).'/inc/listpage.class.php');
include(dirname(__FILE__).'/inc/tree.class.php');
include(dirname(__FILE__).'/inc/article.model.class.php');
include(dirname(__FILE__).'/inc/type.model.class.php');


//文章类
$TR  = new tree();
$DA  = new article();
$DT  = new type();
$LP = new ListPage();
//  /article.php?id=19
//  /article.php?id=86
$tid = isset($_GET['tid'])? intval($_GET['tid']):0;
if(!$tid){ header('location:index.php');die(); }





//当前分类
$type =  $DT->init( $tid );
//if(!$type){ header('location:index.php');die(); }  


//var_dump($type);

//var_dump($DT);

//顶层栏目
//var_dump($DT->top());
//顶层栏目
//var_dump($DT->parent( 15 ));


//var_dump($art);
//var_dump($type);


// 列表页面 'type' => string '1' (length=1)  1.引用 templist模板  2. 引用tempindex模板  3. 跳页

if($type['type'] == 1 ){
	$temp = trim($type['templist']);
	$re = $DA->getList($tid);
	$child = $DT->child($tid);
	//var_dump($child);
	$place = $DT->place($tid);
	$page_arr =   $DT->dl();;
}else if($type['type'] == 2 ){
	//var_dump($type);
	$temp = trim($type['tempindex']);
}else if( $type['type'] == 3 ){
	if(!empty($type['jumpurl'])){
		header('location:' . $type['jumpurl'] );die();
	}else{
		die('跳转链接不存在！！！');
	}
}

$temp = ROOT.'/temp/'.$temp;
//$temp = realpath($temp);


if (file_exists(  $temp   )  and  !is_dir( $temp )) {
    include($temp);
} else {
    echo "模板文件 $temp does not exist";
}


//include($tempart);